import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

const dirname = path.resolve()
const resolve = dir => path.join(dirname, dir)

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],

  resolve: {
    alias: {
    '@': resolve('src'),
    'assets': resolve('src/assets'),
    'common': resolve('src/common'),
    'components': resolve('src/components'),
    'network': resolve('src/network'),
    'views': resolve('src/views'),
    }
  },
  server: {
    proxy: {     // see https://cli.vuejs.org/zh/config/#devserver-proxy
      '/api': {  // see https://github.com/chimurai/http-proxy-middleware#options
        target: 'http://localhost:8001', // target host
        pathRewrite: {'^/api' : ''},     // rewrite path
        ws: true,                        // proxy websockets
        changeOrigin: true               // needed for virtual hosted sites: when setting to true, the proxy server sets the host/port of the request header as the target site. 
      }
    }
  },
})
